package com.xinruke.hostels.dailymanage.controller;

import com.xinruke.hostels.common.controller.BaseController;
import com.xinruke.hostels.common.vo.ResultVO;
import com.xinruke.hostels.common.vo.query.RowsDataVO;
import com.xinruke.hostels.dailymanage.interfaces.dto.inhotel.*;
import com.xinruke.hostels.dailymanage.service.OrderSettleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @ClassName OrderSettleController
 * @CreateDate 2019/7/12
 * @Author FengXinQiang
 * @Version V1.0.0.0
 * @Decription 订单结算Controller
 */
@RestController
@RequestMapping("/orderSettle/")
@Api(tags = "订单结算")
@Slf4j
public class OrderSettleController extends BaseController {
    @Autowired
    OrderSettleService orderSettleService;

    @PostMapping("/getBalanceFlowList")
    @ApiOperation("获取资金流水集合")
    public ResultVO<RowsDataVO<OrderFundsFlowQueryResultDTO>> getFundsFlowList(@RequestBody @Valid OrderFundsFlowQueryDTO orderFundsFlowQueryDTO) {
        ResultVO<RowsDataVO<OrderFundsFlowQueryResultDTO>> resultVO = ResultVO.fail();

        RowsDataVO rowsDataVO = orderSettleService.getFundsFlowList(orderFundsFlowQueryDTO);

        resultVO = ResultVO.success();
        resultVO.setData(rowsDataVO);

        return resultVO;
    }

    @PostMapping("/inMoney")
    @ApiOperation("入账")
    public ResultVO<OrderInMoneyResultDTO> orderInMoney(@RequestBody @Valid OrderInMoneyDTO orderInMoneyDTO) {
        ResultVO<OrderInMoneyResultDTO> resultVO = ResultVO.fail();

        resultVO = orderSettleService.orderInMoney(orderInMoneyDTO);

        return resultVO;
    }

    @PostMapping("/settleRoom")
    @ApiOperation("结账退房")
    public ResultVO<OrderSettleResultDTO> settleRoom(@RequestBody @Valid OrderSettleDTO orderSettleDTO) {
        ResultVO<OrderSettleResultDTO> resultVO = ResultVO.fail();

        resultVO = orderSettleService.settleRoom(orderSettleDTO);

        return resultVO;
    }
}
